package com.song.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TonySong
 * @date 2024/5/10 0010
 * @time 15:50
 */
@RestController
@Slf4j
public class IndexController {

    @GetMapping("/test02")
    public String test02(){
        return "test02";
    }

    @GetMapping("/auth")
    public String auth( String type) {
        log.info("参数：{}",type);
        return "auth-->"+type;
    }
    @GetMapping("/hos1")
    @SentinelResource("/hos1")
    public String getProduct(Long id){
        log.info("查询{}号商品",id);
        return "测试热点规则！编号"+id;
    }


    private int m=0; //全局变量、属性、实例变量
    @GetMapping("/test3")
    public String  test3(){
        log.info("test3");
        if( ++m % 3 == 0){
            throw new RuntimeException("test3");
        }
        return "演示异常比例....";
    }
}
